#ifndef RECIPE_FACTORY_
#define RECIPE_FACTORY_

#include <memory>
#include <string>
#include <vector>
#include "tinyxml.h"
#include "recipe.h"

class XmlParser
{
public:
	bool load_file(std::string filename);
	
private:
	std::unique_ptr<TiXmlDocument> xml_doc;
};


class RecipeFactory
{
public:
   /* Main factory function
	*
	* Tries to create a recipe from an xml file.
	* Value held by returned pointer will be NULL if construction fails.
	*/
	std::unique_ptr<Recipe> get_recipe(std::string drink_key, std::string filename);
	
private:
	//Helper functions for finding the correct node
	TiXmlNode*  			find_drink(std::string drink_key, TiXmlNode* recipes_node);
	
	//Helper functions for navigating the xml structure
	std::string 			get_element_text(TiXmlNode* parent);
	std::string 			get_child_text(std::string name, TiXmlNode* parent);
	
	//Helper function that builds recipe from xml node
	std::unique_ptr<Recipe>	build_recipe(TiXmlNode* drink_node, std::string drink_key);
	
};


#endif
